<template>
    <van-nav-bar title="商品详情页" left-text="返回" left-arrow @click-left="() => { $router.push('/') }" fixed />
    <div style="height: 45px;"></div>
    <div v-html="detailData.goods_introduce">

    </div>
    <van-action-bar>
        <van-action-bar-icon icon="chat-o" text="客服" @click="onClickIcon" />
        <van-action-bar-icon icon="cart-o" text="购物车" @click="onClickIcon" />
        <van-action-bar-icon icon="shop-o" text="店铺" @click="onClickIcon" />
        <van-action-bar-button type="danger" text="加入购物车" @click="onClickButton" />
    </van-action-bar>
</template>

<script setup>
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
const router = useRouter()
import { detailApi } from '@/api/api'
let detailData = ref([])
detailApi(route.params.goods_id).then(res => {
    console.log('详情数据', res.data.message)
    detailData.value = res.data.message
})
import { useCounterStore } from '@/stores/cart'
// 可以在组件中的任意位置访问 `store` 变量 ✨
const store = useCounterStore()
const onClickButton = () => {
    store.addCart(detailData.value, route.params.goods_id)
    router.push('/home/cart')
}
</script>

<style lang="scss" scoped></style>